<?php

class CommonAction extends Action {
	private $db_obj=NULL;
	function _initialize() {
        import('@.ORG.Util.Cookie');
        //import('ORG.Util.RBAC');
         //用户权限检查
        //var_dump(RBAC::getAccessList($_SESSION [C('USER_AUTH_KEY')]));
        //exit;
		//ECHO MODULE_NAME;
        if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
            import('ORG.Util.RBAC');
            //var_dump(RBAC::AccessDecision());
             //exit;
            if (!RBAC::AccessDecision()) {
                //检查认证识别号
                if (!$_SESSION [C('USER_AUTH_KEY')]) {
                    //跳转到认证网关
                    //echo "aa";
                    redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
                }
                // 没有权限 抛出错误
                if (C('RBAC_ERROR_PAGE')) {
                    // 定义权限错误页面
                    redirect(C('RBAC_ERROR_PAGE'));
                } else {
                    if (C('GUEST_AUTH_ON')) {
                        $this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
                    }
                    // 提示错误信息
                    $this->error(L('_VALID_ACCESS_'));
                }
            }
        }
      }
      
      //分页样式设置
      function setPageStyle($page,$name="条记录")
      {
      	
      }
      //管理员操作日志
      public function admin_log($desc)
      {
       $log=new Model("admin_log");
       $act_arr=get_action();
       $data['action']=$action=$act_arr['action'];
       $data['controller']=$controller=$act_arr['controller'];
       $data['admin_id']=$admin_id=$_SESSION['authId'];
       $data['desc']=$desc;
       $data['add_time']=$time=time();
  
       $log->data($data)->add();
      
      }
    }
?>